package com.green.service.manage.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.green.common.page.Pagination;
import com.green.dao.impl.BaseDaoImpl;
import com.green.dao.manage.ComboSetupDao;
import com.green.model.manage.ComboSetup;
import com.green.model.manage.enums.ComboSetupTypeEnum;
import com.green.service.manage.ComboSetupService;



/**
 * 端口设置
 * 
 */
@Repository("comboSetupService")
public class ComboSetupServiceImpl extends BaseDaoImpl implements ComboSetupService {
	@Autowired
	private ComboSetupDao comboSetupDao;
	@Override
	public int insertComboSetup(ComboSetup ct) {
		return comboSetupDao.insertComboSetup(ct);
	}

	@Override
	public int updateComboSetup(ComboSetup ct) {
		return comboSetupDao.updateComboSetup(ct);
	}

	@Override
	public int deleteComboSetup(Map<String, Object> param) {
		return comboSetupDao.deleteComboSetup(param);
	}

	@Override
	public ComboSetup getComboSetupById(String id) {
		return comboSetupDao.getComboSetupById(id);
	}

	@Override
	public List<ComboSetup> getComboSetupList(Map<String, Object> param) {
		return comboSetupDao.getComboSetupList(param);
	}

	@Override
	public Pagination<ComboSetup> getComboSetupPagination(Pagination<ComboSetup> pag,
			Map<String, Object> param) {
		return comboSetupDao.getComboSetupPagination(pag, param);
	}
	
	public List<ComboSetup> getComboSetups(ComboSetupTypeEnum typeEnum,String city){
	    Map<String, Object> param = new HashMap<String, Object>();
	    param.put("ComboSetupType", typeEnum);
	    param.put("isNotFree", "true");
	    param.put("isforbidden", 0);
	    param.put("city", city);
	    return comboSetupDao.getComboSetupList(param);
	}

    @Override
    public ComboSetup getFreeComboSetup(ComboSetupTypeEnum typeEnum,String city) {
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("ComboSetupType", typeEnum);
        param.put("isFree", "true");
        param.put("isforbidden", 0);
        param.put("city", city);
        List<ComboSetup> setups = comboSetupDao.getComboSetupList(param);
        if(setups.size()>0) 
            return setups.get(0);
        return null;
    }
	
	
}
